<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .box {
      width: 400px;
      height: 600px;
      border: 1px solid red;
    }

    .nav {
      list-style: none;
      height: 80px;
      width: 400px;
      background: skyblue;
      font-size: 0px;
    }

    .nav li {
      display: inline-block;
      height: 80px;
      width: 100px;
      border: 1px solid gray;
      box-sizing: border-box;
      font-size: 16px;
    }
    .sel{
      background-color: yellowgreen;
    }
    .content div{
      width: 400px;
      height: 420px;
      background: pink;
    }
  </style>
</head>

<body>

  <div id="app">
    <div class="box">
      <ul class="nav">
        <li v-bind:class='item===seletde?"sel":""' v-for="item in list" v-on:click='change(item)'>{{item}}</li>
      </ul>
      <div class="content">
        <div v-show='item===seletde?true:false' v-for="item in list">
          {{item}}
        </div>
      </div>
    </div>
  </div>

</body>
<script src="./vue.js"></script>
<script>
  let vm = new Vue({
    el: "#app",
    data:{
      list:['爱情','恐怖','动漫','喜剧'],
      seletde:"爱情", //默认选中的一项
    },
    methods:{
      change(item){
        console.log('点到了'+item);
        this.seletde = item;
      }
    }
  })


  /*
    用vue实现tab选项卡
    1.渲染界面
    2.点击切换tab
    3.导航条高亮
    4.内容要切换

    a.先把静态处理出来
    b.哪些元素可以用指令
  */
 
</script>

</html>